﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Nuclex.UserInterface;
using Nuclex.UserInterface.Controls.Desktop;
using Microsoft.Xna.Framework;

using Nuclex.Game.States;
using Nuclex.UserInterface.Controls;

namespace WarPigs
{
    /// <summary>Dialog that demonstrates the capabilities of the GUI library</summary>
    public partial class SinglePlayerDialog : WindowControl
    {

        GameState gameState;
        float dialogWidth;
        float dialogHeight;

        /// <summary>Initializes a new GUI demonstration dialog</summary>
        public SinglePlayerDialog(GameState passedState, float passedWidth, float passedHeight)
        {
            dialogWidth = passedWidth;
            dialogHeight = passedHeight;
            gameState = passedState;
            InitializeComponent();
        }
    }

    partial class SinglePlayerDialog
    {

        #region NOT Component Designer generated code

        /// <summary> 
        ///   Required method for user interface initialization -
        ///   do modify the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            spLabel = new Nuclex.UserInterface.Controls.LabelControl();
            okButton = new Nuclex.UserInterface.Controls.Desktop.ButtonControl();
            cancelButton = new Nuclex.UserInterface.Controls.Desktop.ButtonControl();
            //
            // helloWorldLabel
            //
            spLabel.Text = "SINGLE PLAYER OPTIONS";
            spLabel.Bounds = new UniRectangle(15.0f, 20.0f, 110.0f, 30.0f);
            //
            //Draw rectangle to choose PMCs in game
            //
            pmcWindow = new WindowControl();
            pmcWindow.Bounds = new UniRectangle(3.0f, 45.0f, (dialogWidth / 2.0f), (dialogHeight / 1.1f));
            pmcWindow.EnableDragging = false;
            pmcWindow.BringToFront();
            //
            //Draw rectangle to choose individual game options
            //
            optionsWindow = new WindowControl();
            optionsWindow.Bounds = new UniRectangle((dialogWidth / 2.0f), 45.0f, (dialogWidth / 2.0f), (dialogHeight / 1.1f));
            optionsWindow.EnableDragging = false;
            optionsWindow.BringToFront();
            //
            // okButton
            //
            okButton.Text = "Start Game";
            okButton.Bounds = new UniRectangle(
              new UniScalar(1.0f, -180.0f), new UniScalar(1.0f, -40.0f), 80, 24
            );
            okButton.Pressed +=new EventHandler(okButton_Pressed); //This needs a check for if the options were filled out or not
            //
            // cancelButton
            //
            cancelButton.Text = "Cancel";
            cancelButton.Bounds = new UniRectangle(
              new UniScalar(1.0f, -90.0f), new UniScalar(1.0f, -40.0f), 80, 24
            );
            cancelButton.Pressed += new EventHandler(cancelButton_Pressed);
            //
            //Individual PMC dialogs
            //
            //First is local player

            //
            // SinglePlayerDialog
            //

            Bounds = new UniRectangle(-60.0f, -60.0f, dialogWidth, dialogHeight); //Dialog size is 6/8's screen size

            Children.Add(spLabel);
            Children.Add(okButton);
            Children.Add(cancelButton);
            Children.Add(pmcWindow);
            Children.Add(optionsWindow);
        }

        void okButton_Pressed(object sender, EventArgs e)
        {
            this.Close();
            ((MainMenuGameState)gameState).newGameStart();
        }

        void cancelButton_Pressed(object sender, EventArgs e)
        {
            this.Close();
        }

        #endregion // NOT Component Designer generated code

        /// <summary>A label used to display a 'hello world' message</summary>
        LabelControl spLabel;
        /// <summary>Button which exits the dialog and takes over the settings</summary>
        ButtonControl okButton;
        /// <summary>Button which exits the dialog and discards the settings</summary>
        ButtonControl cancelButton;

        //PMC half of the single player control
        WindowControl pmcWindow;
        private WindowControl optionsWindow;

    }
}
